#ifdef __cplusplus
extern "C"{
#endif

#include "xs_def.h"

int xs_file_length(const char* path)
{
    struct stat st;
    int ret = lstat(path, &st);
    if(ret < 0)
        return ret;

    if(S_ISREG(st.st_mode))
        return st.st_size;

    return -1;
}

int xs_file_exist(const char* path)
{
    struct stat st;
    int ret = lstat(path, &st);
    if(ret < 0)
        return 0;

    if(S_ISREG(st.st_mode))
        return 1;

    return 0;

}

int xs_dir_exist(const char* path)
{
    struct stat st;
    int ret = lstat(path, &st);
    if(ret < 0)
        return 0;

    if(S_ISDIR(st.st_mode))
        return 1;
    return 0;

}

#ifdef __cplusplus
}
#endif
